package com.example.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

// 通过注解的方式定义后端控制器
@Controller
public class SecondController {

    /*
    @GetMapping("/second")
    public String second(HttpServletRequest request) { // 直接通过参数传入一个HttpServletRequest

        // 通过HttpServletRequest获取参数的值。参数包含在查询字符串或已发布的表单数据中
        String id = request.getParameter("id");
        System.out.println("id:" + id);

        return "/WEB-INF/jsp/index.jsp";
    }
    */

    @GetMapping("/second")
    public String second(String id) {

        System.out.println("id:" + id);

        return "/WEB-INF/jsp/index.jsp";
    }
}
